function [coordmatrix,xdata,ydata,Z2d] = For_nlinfit2D(ODin)

[horiz,vert] = size(ODin);  % y-dir. is HORIZ. exper. dir.; x-dir. is VERT
% Creating matrices for 2D fitting with ODin
xvec=1:vert;
yvec=1:horiz;
Npts=vert*horiz;
[xdata,ydata]=meshgrid(xvec,yvec);  % xdata(ydata) have columns=length(xvec), rows=length(yvec)
% xdata copies xvec along its rows; ydata copies yvec along its columns

error2d(1:Npts)=1;   % DUMMY
npoints(1:Npts)=Npts;   % DUMMY - Each entry is the number of points
coordmatrix=[xdata(:),ydata(:),error2d(:),npoints(:)];

Z2d=ODin(:);  %flattened(1D) vector of ODin
end